package com.andyage.admin.action;
import java.io.IOException;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import com.andyage.admin.service.IAdStaffService;
import com.andyage.admin.bean.AdstaffBean;




@Controller
@RequestMapping("/admin")
public class AdStaffAction {
	@Resource
	private IAdStaffService iAdStaffService;
	@RequestMapping("/AdStaffLogin")
	public  void AdStaffLogin(HttpServletRequest request,HttpServletResponse response) {
			try {
			iAdStaffService.AdStaffLogin(request,response);
			} catch (Exception e) {
				e.printStackTrace();
			}
			return ;
	}
	/**
	 * 查询管理员表
	 * @return
	 */
	@RequestMapping("/queryAdStaffInfo")
	public void queryAdStaffInfo(AdstaffBean adstaff,HttpServletRequest request,HttpServletResponse response) {
		try {
			iAdStaffService.queryAdStaffInfo(adstaff,request,response);
		} catch (Exception e1) {
			e1.printStackTrace();
		}
	}
	/**
	 * 添加管理员
	 * @param AdStaffBean
	 * @param response
	 * @throws Exception 
	 */
	@RequestMapping("/addAdStaffInfo")
	public  void addAdStaffInfo(HttpServletRequest request,HttpServletResponse response){
			try {
				iAdStaffService.addAdStaffInfo(request,response);
			} catch (Exception e) {
				e.printStackTrace();
			}
		
	}
	@RequestMapping("/deleteAdStaffInfo")
	public  void deleteAdStaffInfo(HttpServletRequest request,HttpServletResponse response) {
			try {
				iAdStaffService.deleteAdStaffInfo(request,response);
			} catch (Exception e) {
				e.printStackTrace();
			}
	}
	@RequestMapping("/updateAdStaffInfo")
	public void updateAdStaffInfo(HttpServletRequest request,HttpServletResponse response) {
		try {
			iAdStaffService.updateAdStaffInfo(request,response);
		} catch (Exception e) {
			e.printStackTrace();
		}
}
	@RequestMapping("/loginOut")
	public void loginOut(HttpServletRequest request,HttpServletResponse response) {
		String StaffAccount=(String) request.getSession().getAttribute("StaffAccount");
		if(StaffAccount!=null&&!"".equals(StaffAccount)){
			request.getSession().invalidate();
			try {
				request.getRequestDispatcher("/adminLogin.jsp").forward(request, response);
			} catch (ServletException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
		}
		return;
	}
	@RequestMapping("/queryCommonStaff")
	public void queryCommonStaff(HttpServletRequest request,HttpServletResponse response) {
		try {
			iAdStaffService.queryCommonStaff(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	@RequestMapping("/updateStaffPwd")
	public void updateStaffPwd(HttpServletRequest request,HttpServletResponse response) {
		try {
			iAdStaffService.updateStaffPwd(request, response);
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}
